<div class="menu_top">
	<input type="hidden" name="action" value="editor_shipping_rules" />
    <input type="hidden" name="shipping" value="<?php echo $_REQUEST['shipping']; ?>" />
    <input type="hidden" name="edit" value="rules" />
    <input type="hidden" name="zone" value="<?php echo $_REQUEST['zone']; ?>" />
	<img title="<?php echo ucfirst($txt->getWord('save')); ?>" class="icon command" src="<?php echo SYSICONS_URL; ?>filesave_22.gif" onclick="edit_form.submit();"  />
</div>
<?php $colspan = count($zones); ?>
<div class="menu_list">
<table id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
	<thead class="fields">
        <tr>
            <th class="first center">&nbsp;&nbsp;#&nbsp;&nbsp;</th>
            <th><?php echo ucfirst($txt->getWord('title')); ?></th>
            <th><?php echo ucfirst($txt->getWord('min_weight')); ?></th>
            <th><?php echo ucfirst($txt->getWord('max_weight')); ?></th>
            <th><?php echo ucfirst($txt->getWord('min_volume')); ?></th>
            <th><?php echo ucfirst($txt->getWord('max_volume')); ?></th>
			<th><?php echo ucfirst($txt->getWord('zone').' '.$txt->getWord('price')); ?></th>
            <?php if($shop->GlobalSettings['shipping_weekend_delivery']): ?>
            <th><?php echo ucfirst($txt->getWord('saturday').' '.$txt->getWord('price')); ?></th>
            <th><?php echo ucfirst($txt->getWord('sunday').' '.$txt->getWord('price')); ?></th>
            <?php endif;  ?>
            <th><?php echo ucfirst($txt->getWord('new')); ?></th>
            <th class="last"><?php echo ucfirst($txt->getWord('delete')); ?></th>
        </tr>
    </thead>
    <tbody>
        <tr class="items">
            <td class="first center">0</td>
            <td><input class="small" id="new_rule" name="new_rule[]" type="text" value="" maxlength="30" /></td>
            <td><input class="xsmall" name="new_rule_min_weight[]" type="text" value="0" maxlength="9" /></td>
            <td><input class="xsmall" name="new_rule_max_weight[]" type="text" value="0" maxlength="9" /></td>
            <td><input class="xsmall" name="new_rule_min_volume[]" type="text" value="0" maxlength="9" /></td>
            <td><input class="xsmall" name="new_rule_max_volume[]" type="text" value="0" maxlength="9" /></td>
            <td>
            	<select class="small" name="new_rule_zone[]" >
                	<option value="0"><?php echo ucfirst($txt->getWord('all')); ?></option>
                    <?php 
                    if($zones)
					{
						foreach($zones as $zone)
                        { echo '<option value="'.$zone['id'].'" '.getIsSelectedHTML($zone['id'], $_REQUEST['zone']).'>'.$zone['title'].'</option>'; }
                    }
                    ?>
                </select>:<input class="xsmall" name="new_rule_price[]" type="text" value="0" maxlength="9" />
            </td>
            <?php if($shop->GlobalSettings['shipping_weekend_delivery']): ?>
            <td><input class="xsmall numeric" name="new_rule_price_delivery_saturday[]" type="text" value="0" maxlength="9" /></td>
            <td><input class="xsmall numeric" name="new_rule_price_delivery_sunday[]" type="text" value="0" maxlength="9" /></td>
            <?php endif;  ?>
            <td class="center">
            	<img 
                	title="<?php echo ucfirst($txt->getWord('new')); ?>"
                    class="icon command" 
                    src="<?php echo SYSICONS_URL; ?>add_16.gif" 
                    onclick="if(document.getElementById('new_rule').value != '') { edit_form.submit(); }" />
            </td>
        </tr>
        <?php 
        if($rules)
		{
			foreach($rules as $rule)
			{ 
            ?>
            <tr class="items">
                <td class="first center"><?php echo $rule['id']; ?><input type="hidden" name="rule_id[]" value="<?php echo $rule['id']; ?>" /></td>
                <td><input class="small" name="rule_title[]" type="text" value="<?php echo $rule['title']; ?>" maxlength="30" /></td>
                <td><input class="xsmall int" name="rule_min_weight[]" type="text" value="<?php echo $rule['min_weight']; ?>" maxlength="9" /></td>
                <td><input class="xsmall int" name="rule_max_weight[]" type="text" value="<?php echo $rule['max_weight']; ?>" maxlength="9" /></td>
                <td><input class="xsmall int" name="rule_min_volume[]" type="text" value="<?php echo $rule['min_volume']; ?>" maxlength="9" /></td>
                <td><input class="xsmall int" name="rule_max_volume[]" type="text" value="<?php echo $rule['max_volume']; ?>" maxlength="9" /></td>
                <td>
                	<select class="small" name="rule_zone[]" >
                        <option value="0" <?php echo getIsSelectedHTML(0, $rule['zone_id']); ?>><?php echo ucfirst($txt->getWord('all')); ?></option>
                        <?php 
                        if($zones)
                        {
                            foreach($zones as $zone)
                            { echo '<option value="'.$zone['id'].'" '.getIsSelectedHTML($zone['id'], $rule['zone_id']).'>'.$zone['title'].'</option>'; }
                        }
                        ?>
                    </select>:<input class="xsmall numeric price" name="rule_price[]" type="text" value="<?php echo $rule['price']; ?>" maxlength="9" />
                </td>
                <?php if($shop->GlobalSettings['shipping_weekend_delivery']): ?>
                <td><input class="xsmall numeric" name="rule_price_delivery_saturday[]" type="text" value="<?php echo $rule['price_delivery_saturday']; ?>" maxlength="9" /></td>
                <td><input class="xsmall numeric" name="rule_price_delivery_sunday[]" type="text" value="<?php echo $rule['price_delivery_sunday']; ?>" maxlength="9" /></td>
                <?php endif;  ?>
                <td>&nbsp;</td>
                <td class="last center">
					<input title="<?php echo ucfirst($txt->getWord('delete')); ?>" class="inp_image" type="image" name="delete_rule" src="<?php echo SYSICONS_URL; ?>delete_16.gif" value="0" onclick="this.value='<?php echo $rule['id']; ?>'; edit_form.submit();" />
				</td>
            </tr>
            <?php
			}
        }
        ?>
	</tbody>
</table>
</div>